//
//  ProvinceAndCityView.m
//  RNIbuildModuleBaiduMap
//
//  Created by Wentao Ye on 19/05/2017.
//  Copyright © 2017 Facebook. All rights reserved.
//


#import "ProvinceAndCityView.h"

@implementation ProvinceAndCityView

-(instancetype)init{
    self = [super init];
    if (self) {
        
    }
    return  self;
}

-(id)initWithFrame:(CGRect)frame
{
    if ((self = [super initWithFrame:frame])) {
        
        self.backgroundColor = [UIColor whiteColor];
        self.lblProvinceName = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, 30.f)];
        [self.lblProvinceName setUserInteractionEnabled:YES];
        self.lblProvinceName.backgroundColor = [UIColor clearColor];
        self.lblProvinceName.numberOfLines = 1;
        self.lblProvinceName.font = [UIFont systemFontOfSize:15.f];
        self.lblProvinceName.textColor = [UIColor blackColor];
        self.lblProvinceName.textAlignment = NSTextAlignmentCenter;
        [self addSubview:self.lblProvinceName];
        
        
        self.lblProjectCount = [[UILabel alloc] initWithFrame:CGRectMake(0, self.lblProvinceName.frame.origin.y +self.lblProvinceName.frame.size.height , frame.size.width, 20.f)];
        self.lblProjectCount.backgroundColor = [UIColor clearColor];
        self.lblProjectCount.numberOfLines = 1;
        self.lblProjectCount.font = [UIFont systemFontOfSize:12.f];
        self.lblProjectCount.textColor = [UIColor redColor];
        self.lblProjectCount.textAlignment = NSTextAlignmentCenter;
        [self addSubview:self.lblProjectCount];
        [self setUserInteractionEnabled:YES];
        
        UITapGestureRecognizer *tapRecg = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped:)];
        [self.lblProvinceName addGestureRecognizer:tapRecg];
        
    }
    return self;
}
-(void) setDisplayInfo:(BDMapAnnotation *)info withMode:(NSInteger)mode
{
    //    self.annotationInfo = info;
    //    self.provinceID = info.provinceID;
    //    if (info.provinceName) {
    //        self.lblProvinceName.text =  mode ==  0 ?info.provinceName:info.cityName;
    //    }
    //    if (info.projectCount) {
    //        self.lblProjectCount.text = [NSString stringWithFormat:@"(当前共有%li个项目)",info.projectCount];
    //    }
}

-(void)viewTapped:(UITapGestureRecognizer *)sender
{
    [self.delegate ProvinceAndCityView:self clickViewWithData:self.annotationInfo];
}
@end
